package com.study.async.Controller;

import com.study.async.service.AsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @author : wilbur.yuan
 * @date : 2019-02-20
 */
@RestController
@RequestMapping("/hello")
public class HelloWorldController {

    @Autowired
    private AsyncService asyncService;

    @GetMapping
    public String get() throws InterruptedException, ExecutionException {
        Future<String> test1F = asyncService.test1();
        Future<String> test2F = asyncService.test2();
        Future<String> test3F = asyncService.test3();

        return test1F.get() + test2F.get() + test3F.get();
    }

}
